<?php 
include '../inc/reuse/dbconfig.php';

$main_id = "";
$sub_id = "";
if(isset($_GET['main_id']))
	$main_id = $_GET['main_id'];
else 
	$main_id = $default_main;

if(isset($_GET['sub_id']))
	$sub_id = $_GET['sub_id'];
else
	$sub_id = $default_main;

if($main_id != "")
{
	$sql = "SELECT * FROM fix_main_products_type WHERE fix_main_products_type_id =".$main_id;
	$rsd = mysql_query($sql);
	$row = mysql_fetch_array($rsd);
	$mainCategory = $row['fix_main_products_type_name'];
	
	$sql = "SELECT * FROM fix_sub_products_type WHERE fix_main_products_type_id =".$main_id;
	$rsd = mysql_query($sql);
	while($row = mysql_fetch_array($rsd)){
		echo "<tr>
	        	<td>".$row['fix_sub_products_type_id']."</td>
	            <td>".$mainCategory."</td>
	            <td>".$row['fix_sub_products_type_name']."</td>
	            <td align=\"center\"><a href=\"#\" onClick=\"goToEditSubCategory(".$row['fix_sub_products_type_id'].",'".$row['fix_sub_products_type_name']."')\"\"><img src=\"images/symbol/edit.png\" /></a></td>
	            <td align=\"center\"><a href=\"#\" onClick=\"deleteSubCategory(".$row['fix_main_products_type_id'].",".$row['fix_sub_products_type_id'].",'".$row['fix_sub_products_type_name']."')\" ><img src=\"images/symbol/delete.png\" /></a></td>			 
			  </tr>";
	}	
}
else
{
	echo "<tr><td colspan=5 align=\"center\">กรุณาเพิ่มสินค้าหลักก่อน</td></tr>";
}
?>